﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace WorldViewSolutions.ArcGISServer.SOE
{
    /// <summary>
    /// Static class that contains various methods to create URLs
    /// </summary>
    /// <remarks></remarks>
    public static class UrlHelper
    {
        /// <summary>
        /// Creates a new url from the given parts. 
        /// </summary>
        /// <param name="baseUrl">The base URL.</param>
        /// <param name="relativeUrl">The url to append to the end of the base URL.</param>
        /// <returns></returns>
        /// <remarks></remarks>
        public static string Combine(string baseUrl, string relativeUrl)
        {
            char[] slash = new char[] { '/', '\\' };
            baseUrl = baseUrl.Replace('\\', '/');
            baseUrl = baseUrl.TrimEnd(slash);

            relativeUrl = relativeUrl.Replace('\\', '/');
            relativeUrl = relativeUrl.TrimStart(slash);

            return baseUrl + "/" + relativeUrl;
        }
    }
}